package com.woniuxy.qiantai.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ShortMessageQueue {

    /**
     * 验证码队列
     */
    @Bean
    public Queue verification(){
        return new Queue("verification");
    }

    /**
     * 用户 账号密码短信发送
     */
    @Bean
    public Queue userInformation(){
        return new Queue("userInformation");
    }
    /**
     * 重置密码的队列
     * @return
     */
    @Bean
    public Queue resetPassword(){
        return new Queue("resetPassword");
    }
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("directExchange");
    }

    /**
     * 验证码 routing key
     */
    @Bean
    public Binding verificationBinding(){
        return BindingBuilder.bind(verification()).to(directExchange()).with("code");
    }

    /**
     * 账户 routing key
     */
    @Bean
    public Binding userInformationBinding(){
        return BindingBuilder.bind(userInformation()).to(directExchange()).with("user");
    }

    /**
     * 重置密码队列绑定 routing key
     */
    @Bean
    public Binding resetPasswordBinding(){
        return BindingBuilder.bind(resetPassword()).to(directExchange()).with("password");
    }
}
